<!DOCTYPE html>
<html>

<meta charset="utf-8">
<head th:include="include :: header"></head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">

    <div class="row">
        <div class="col-sm-12">

            <div class="ibox-content">
                <form class="form-horizontal m-t" id="uploadForm" enctype="multipart/form-data">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">请选择上传文件：</label>
                        <div class="col-sm-8">
                            <input id="file" name="file" class="form-control"
                                   type="file" multiple="multiple">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-8 col-sm-offset-3">
                            <button type="submit" class="btn btn-primary"  onclick="uploadFile()">提交</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4"></script>
<script src="/js/bootstrap.min.js?v=3.3.6"></script>

<!-- 自定义js -->
<script src="/js/content.js?v=1.0.0"></script>

<!-- jQuery Validation plugin javascript-->
<script src="/js/plugins/validate/jquery.validate.min.js"></script>
<script src="/js/plugins/validate/messages_zh.min.js"></script>

<script type="text/javascript">
    function uploadFile() {
        if ($('#file')[0].files[0]==undefined){
            parent.layer.msg("请选择导入文件");
        }
        var formDate = new FormData($('#uploadForm')[0]);
        console.log(formDate);
        $.ajax({
            cache : true,
            type : "POST",
            url : "/experts/expertExpertsInfo/uploadFile",
            data : formDate,
            async: false,
            processData: false,
            contentType: false,
            error : function(request) {
                parent.layer.msg(data.msg);
                var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                parent.layer.close(index);
            },
            success : function(data) {
                if (data.code == 0) {
                    parent.layer.msg(data.msg);
                    $(window.parent.document).find('.J_iframe').each(function () {
                        if ($(this).data('id') == "/experts/expertExpertsInfo") {//common/sysDict为打开的frame id
                            this.contentWindow.reLoad();
                            return false;
                        }
                    });
                } else {
                    parent.layer.msg(data.msg);
                }
                var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                parent.layer.close(index);
            }
        });
    }
</script>
</body>

</html>
